extends ../../layout

block css
    link(rel="stylesheet", href="/css/addon/form-file.almost-flat.min.css")
    link(rel="stylesheet", href="/css/dashboard/overlayer.css")
    link(rel="stylesheet", href="/css/dashboard/navbar.css")
    link(rel="stylesheet", href="/css/dashboard/contract-list.css")
block js
    script(data-main="/js/entry/contract" src="/js/lib/require.js")
block content
    include ../includes/navbar.pug
    +active("contract")
    section.ds-sc-list.uk-container.uk-container-center
        - var cache = [];
        h1
            i.uk-icon-globe.uk-margin-right
            | Public Smart Contracts
        table.uk-table.uk-table-hover
            thead
                tr
                    th(width="20%") Name
                    th(width="60%") Description
                    th(width="10%") Version
                    th(width="10%") Author
            tbody
                each contract in public.contracts
                    -
                        cache.push({
                            id: contract.id,
                            deploy: contract.deploy
                        });
                    tr
                        td
                            label= contract.name
                            .uk-button-dropdown.uk-float-right.uk-margin-right(data-uk-dropdown)
                                div
                                    i.uk-icon-chevron-circle-down(style="color:#ff5003;")
                                .uk-dropdown.uk-dropdown-small
                                    ul.uk-nav.uk-nav-dropdown
                                        li
                                            a(data-type="deploy" data-contract-id=`${contract.id}`)
                                                img.img-dropdown(src="/images/icon-deploy-small.svg")
                                                | Deploy
                        td.break_word!= contract.description
                        td= contract.version
                        td= contract.author
                else
                    tr
                        td.no-result(colspan="4") No result.
        ul#publicContractPagination.uk-pagination.uk-pagination-right(
            data-uk-pagination=`{pages:${public.totalPage}}`)&attributes(
            public.contracts.length ? {} : {"style": "display:none;"})
        .add-section
            a.not-active
                img.uk-align-left.gray(src="/images/buy.png" width="29" height="29")
                | Get New Contract
        h1(style="margin-top:100px;")
            i.uk-icon-lock.uk-margin-right
            | Private Smart Contracts
        table.uk-table.uk-table-hover
            thead
                tr
                    th(width="20%") Name
                    th(width="60%") Description
                    th(width="10%") Version
                    th(width="10%") Author
            tbody
                each contract in private.contracts
                    -
                        cache.push({
                            id: contract.id,
                            deploy: contract.deploy
                        });
                    tr
                        td
                            label= contract.name
                            .uk-button-dropdown.uk-float-right.uk-margin-right(data-uk-dropdown)
                                div
                                    i.uk-icon-chevron-circle-down(style="color:#ff5003;")
                                .uk-dropdown.uk-dropdown-small
                                    ul.uk-nav.uk-nav-dropdown
                                        li
                                            a(data-type="deploy" data-contract-id=`${contract.id}`)
                                                img.img-dropdown(src="/images/icon-deploy-small.svg")
                                                | Deploy
                                        li
                                            a(
                                                data-type="edit"
                                                data-contract-id=`${contract.id}`
                                                data-contract-name=`${contract.name}`
                                                data-contract-description=`${contract.description}`
                                                data-contract-version=`${contract.version}`
                                                data-contract-author=`${contract.author}`
                                            )
                                                i.uk-icon-pencil.uk-margin-right
                                                | Edit
                                        li
                                            a(data-type="delete" data-contract-id=`${contract.id}`)
                                                i.uk-icon-trash.uk-margin-right
                                                | Delete
                        td.break_word!= contract.description
                        td= contract.version
                        td= contract.author
                else
                    tr
                        td.no-result(colspan="4") No result.
        ul#privateContractPagination.uk-pagination.uk-pagination-right(
            data-uk-pagination=`{pages:${private.totalPage}}`)&attributes(
            private.contracts.length ? {} : {"style": "display:none;"})
        .add-section
            a
                img.uk-align-left(src="/images/upload.svg")
                | Upload New Contract
        input#cache(type="hidden" value=cache)
        div(style="height:150px;")